package com.ww.springboot.mybatis.controller;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ww.springboot.mybatis.service.IPropagationService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 描述：
 *
 * @author 🧑 ‍wanwei
 * @since 2022-10-17 18:24
 */
@RequestMapping("transactional")
@RestController
@AllArgsConstructor
public class TransactionalController {

    private final IPropagationService propagationService;


    /**
     * 1.Transaction rolled back because it has been marked as rollback-only
     * 场景：如果两个事务,一个让回滚 一个让提交 事务依旧会回滚 同时打印这种信息
     * 结论：如果两个事务为同一事务，只要有一个需要回滚就都会回滚;
     *
     * @param flag1
     * @param flag11
     * @param flag2
     * @return
     */
    @RequestMapping("test")
    public String test(Boolean flag1, Boolean flag11, Boolean flag2) {
        propagationService.test(flag1, flag11, flag2);
        return "success";
    }
}
